package com.usefullc.english.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.usefullc.common.util.BeanUtils;
import com.usefullc.english.domain.ContentShare;
import com.usefullc.english.mapper.ContentShareMapper;
import com.usefullc.english.query.ContentShareQuery;
import com.usefullc.english.vo.ContentShareVo;
import com.usefullc.system.entity.Pager;
import com.usefullc.system.service.AbstractBizService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 内容分享服务类
 * @author: 星空
 * @date: 2022-08-07
 */
@Service
public class ContentShareService extends AbstractBizService<ContentShareMapper, ContentShare, ContentShareQuery> {


    @Override
    protected QueryWrapper<ContentShare> getQueryWrapper(ContentShareQuery query) {
        QueryWrapper<ContentShare> queryWrapper = super.getQueryWrapper(query);
        return queryWrapper;
    }

    public Pager<ContentShareVo> findVoByPage(ContentShareQuery query){
        Pager<ContentShare> page = this.findByPage(query);
        Pager<ContentShareVo> newPage = new Pager<>(page);
        List<ContentShare> dataList = page.getDataList();
        List<ContentShareVo> newDataList = new ArrayList<>();
        newPage.setDataList(newDataList);
        for (ContentShare contentShare : dataList) {
            ContentShareVo contentShareVo = BeanUtils.beanCopy(contentShare, ContentShareVo.class);
            newDataList.add(contentShareVo);
        }
        return newPage;
    }


}
